<?php 
require_once("../includes/config.php"); 
  $length = 20;
  
  if( isset($_POST['page'])  && !empty($_POST['page'] ))
  {
    $page =  filter_var($_POST['page'], FILTER_SANITIZE_NUMBER_INT);
    $start = $page*20 - 20;
  }
  else
  {
    $start = 0;
    $page = 1;
  }
  $sql="SELECT * FROM apartments_owner WHERE id=? ";
 
 $sqlCount = "SELECT COUNT(*) FROM apartments_owner WHERE id=? ";
	   
	   $binds = array();
    $binds['owner_id'] = $_SESSION['user_id'];
	if(!empty($_POST['name']) )
  {
    $binds['name'] = $_POST['name'];
    $sql .= " and MATCH (first_name) AGAINST (? IN BOOLEAN MODE) ";
    $sqlCount .= " and MATCH (first_name) AGAINST (? IN BOOLEAN MODE) ";
  }
 
  $sql .= " LIMIT ?,?";
  $binds['start'] = $start;
  $binds['end'] = $length;
  $employees = query($sql,$binds);
  $Count = query($sqlCount,$binds);
  $totalPages = $Count[0]['COUNT(*)'];
  
  
  
   
    render("employee_reports.php", array("title"=>"تقرير حركة الموظفين","employees"=>$employees,"page"=>$page,"totalPages"=>$totalPages,"start"=>$start,"length"=>$length,"binds"=>$binds));
  ?>
